package com.wyb.mapper;

import com.wyb.pojo.Article;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author wyb
 * @since 2022-10-18
 */
@Mapper
public interface ArticleMapper extends BaseMapper<Article> {

    @Select("select * from sys_article where user_id = #{userId} and is_delete = 0")
    List<Article> selectListByUserId( int userId);

    @Update("update sys_article set liked = liked + 1 where id = #{id}")
    Integer likedAdd(int id);
    @Update("update sys_article set liked = liked - 1 where id = #{id}")
    Integer likedSub(int id);
    @Update("update sys_article set unliked = unliked + 1 where id = #{id}")
    Integer unlikedAdd(int id);
    @Update("update sys_article set unliked = unliked - 1 where id = #{id}")
    Integer unlikedSub(int id);
}
